import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;

public class Test07 {
    public static void main(String[] args) {
        File f1=new File("D:\\aaa");
        String[] arr2=f1.list();
        for (String s : arr2) {
            System.out.println(s);
        }
        System.out.println("======");
        File f2=new File("D:\\aaa");
        String[] arr3=f2.list(new FilenameFilter(){
            @Override
            public boolean accept(File dir,String name){
                File src=new File(dir,name);
                return src.isFile()&&name.endsWith(".txt");

            }
        });
        System.out.println(Arrays.toString(arr3));
    }
}
